package com.caipiao.lottery.task.keepline.danmu;

import com.caipiao.lottery.config.Config;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.ie.InternetExplorerDriver;

import java.io.File;

/**
 * Created by Administrator on 2016/11/17.
 */
public class CookieUtile {
    private static CookieUtile instance = null;
    private static WebDriver driver = null;
    public static boolean flag = true;

    private CookieUtile()
    {
    }

    public static void main(String[] args) {
        String str = "123456";
        System.out.println(str.substring(0,4) +"--"+ str.substring(3,str.length()));
    }

    public static CookieUtile Instance() {
        if (null == instance) {
            instance = new CookieUtile();
        }

        return instance;
    }

    public WebDriver getDriver() {
        if (null == driver) {
            File file = new File(Config.Init.GetPropValue("chromeDriverFilePath"));
            System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
//            //设置chrome执行文件
//            ChromeOptions options = new ChromeOptions();
//            options.setBinary(Config.Init.GetPropValue("chromeFilePath"));
//            driver = new ChromeDriver(options);;
//            driver = new ChromeDriver();
            System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
            driver = new InternetExplorerDriver();
        }

        return driver;
    }

    public void clearDriver() {
        driver = null;
    }

}
